<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>工厂模式</title>
  </head>

  <body>

  </body>
  <script>
    /* 

    */
    // 把 一个一个 创建对象的代码 - 封装起来 - 只要给了不同的参数，就能生产出多个 人  对象
    function createPerson(name, age, gender, height, weigth) {
      var person = new Object()
      person.name = name
      person.age = age
      person.gender = gender
      person.height = height
      person.weight = weigth
      person.sayHi = function () {}
      return person;
    }

    let p1 = createPerson('狗蛋', 16, '男', 160, '80kg')

    function createDog(name, age, gender, height, weigth) {
      var dog = new Object()
      dog.name = name
      dog.age = age
      dog.gender = gender
      dog.height = height
      dog.weight = weigth
      dog.sayHi = function () {}
      return dog;
    }
    let d1 = createDog('旺财', 3, '公', 100, '30kg')
    console.log(p1);
    console.log(d1);
  </script>

</html>